/** 加载页面 */
cc.Class({
    extends: cc.Component,

    properties: {
        /** 提示文字 */
        txt_tip:cc.Label,
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        let urls = ["json/alchemy", "json/build", "json/code", "json/gem", "json/good", "json/guide", "json/gwcoin", "json/heroadd", "json/herolist", "json/magic", "json/monster", "json/npc", "json/task", "json/technique", "json/troop"]; //原生平台只支持图片资源只能发本地了
        cc.loader.loadResArray(urls, cc.JsonAsset, function(completedCount, totalCount, item){
            App.C[item.content.name] = item.content.json;
            this.txt_tip.string = "正在下载" + completedCount + "/" + totalCount;
        }.bind(this), function(errs, assets){
            //console.log(JSON.stringify(App.C));
            if(errs){
                for(let k in errs){
                    cc.log('Error url [' + k + ']: ' + assets.getError(k));
                }
                for (let i=0;i<errs.length;i++) {
                    cc.log('Error url [' + errs[i] + ']: ' + assets.getError(errs[i]));
                }
                return;
            }
            //cc.log("complete",assets);
            /*cc.director.preloadScene("main", function () {
                cc.log("complete end");
                if(App.U.uid) cc.director.loadScene("main");
                else cc.director.loadScene("newhero");
            });*/
        })

        App.enterGame(this);
        App.init();
    },

    // update (dt) {},
    onNetData(msg){
        if(msg[0] == 0){
            switch (msg[1]) {
                case 101:{ //登录成功
                    App.U = msg[2];
                    cc.director.loadScene("main");
                    break;
                }
            }
        }
    },
});
